12 February 2022
CTD casts from eDNA sampling off the Sashin on 10 May, 2021.
library(tidyr)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(readr)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(stringr)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(lubridate)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(hms)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(dplyr)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(ggplot2)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(RColorBrewer)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
library(lubridateExtras)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# read in all files in the reheaded directory
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# dataFiles <- lapply(Sys.glob("CTDCasts/reheaded/*.csv"), read_csv)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# # turn each of the data frames in that list into a single data frame
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# ctd.data <- do.call("rbind", dataFiles)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ctd.w.tides.dist <- read_csv("../data/ctdDataframe.csv") %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(distance != 100)
Rows: 2538 Columns: 16── Column specification ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Delimiter: ","
chr (2): ctd_sample, tide
dbl (13): lat, long, depth_m, salinity, density, pressure_decibar, temp_c, conductivity, sp_conduct, sound_velocity, duration, id, distance
dttm (1): time
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# organize the headers, etc.
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# ctd.data2 <- ctd.data %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# rename(pressure_decibar = `Pressure (Decibar)`, depth_m = `Depth (Meter)`, temp_c = `Temperature (Celsius)`, conductivity = `Conductivity (MicroSiemens per Centimeter)`, sp_conduct = `Specific conductance (MicroSiemens per Centimeter)`, salinity = `Salinity (Practical Salinity Scale)`, sound_velocity = `Sound velocity (Meters per Second)`, density = `Density (Kilograms per Cubic Meter)`, file = `% File name`, lat = `% Start latitude`, long = `% Start longitude`, duration = `% Cast duration (Seconds)`, time = `% Cast time (local)`) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# separate(file, into = c(NA, NA, "ctd_sample"), sep = "_") %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# select(ctd_sample, time, lat, long, depth_m, salinity, density, pressure_decibar, temp_c, conductivity, sp_conduct, sound_velocity, duration)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# # add tide info
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# ctd.w.tides <- ctd.data2 %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# mutate(tide = ifelse(hour(hms::as_hms(time)) >12, "PM_outgoing", "AM_incoming"))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# ctd.w.tides %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# select(lat) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# unique() %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# arrange(lat)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
This will match the other plots in the series.
# meta <- read_csv("../metadata/amalga_clean_metadata.csv")
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# dist <- meta %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# filter(!is.na(distance)) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# arrange(distance) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# select(distance) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# unique()
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# dist2x <- dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# bind_rows(dist)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# # each cast (ctd_sample) represents one of the 80m sampling intervals
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# ctd.w.dist <- ctd.w.tides %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# arrange(time) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# select(time) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# unique() %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# mutate(id = row_number()) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# bind_cols(dist2x)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# # bind it back together
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# ctd.w.tides.dist <- ctd.w.tides %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# left_join(., ctd.w.dist)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# QC: are the data what we think they are?
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggplot(aes(x = long, y = lat, color = tide, linetype = tide, label = ctd_sample)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# geom_line() +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#geom_point(size = 0.1)+
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_text(size = 2.5)+
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
facet_grid(rows = vars(tide)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme_bw()+
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme(
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.x = element_text(margin = margin(t=10)),
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.y = element_text(margin = margin(r=10))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
labs(y = "Latitude",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
x = "Longitude") +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
scale_color_manual(values = c("firebrick1", "midnightblue"))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggsave("pdf_outputs/ctdSimpleLatLon.pdf")
Saving 7.29 x 4.51 in imageError in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Output that dataframe so that I can plot the transect on the bathy map
# ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# write_csv("csv_outputs/ctdDataframe.csv")
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Ultimately, turn this into a map of the transect rather than an x-y plot.
max/min surface water temperature vs. at depth
ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#filter(distance == 0) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggplot(aes(x = temp_c, y = -1*depth_m, color = tide)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_point()
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(depth_m > 9 & depth_m < 11) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
summarise(min(temp_c))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
group_by(tide) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(depth_m > 1) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
summarise(min(temp_c))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# salinity
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(salinity > 20) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggplot(aes(x = density, y = -1*(depth_m), color = distance)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_point() +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
facet_grid(rows = vars(tide)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme_bw()+
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme(
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.x = element_text(margin = margin(t=10)),
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.y = element_text(margin = margin(r=10))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
labs(y = "Depth (m)",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
x = "Density",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
color = "Distance")
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#ggsave("pdf_outputs/ctdSalinityProfile.pdf", width = 8, height = 5)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Salinity: zoomed in
# temp
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(salinity > 20) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(depth_m < 10) %>% # top three meters of the surface
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggplot(aes(x = density, y = -1*(depth_m), color = distance)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_point() +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
facet_grid(rows = vars(tide)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme_bw()+
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme(
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.x = element_text(margin = margin(t=10)),
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.y = element_text(margin = margin(r=10))) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
labs(y = "Depth (m)",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
x = "Density (kg/m^3)",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
color = "Distance (m)")
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
#ggsave("pdf_outputs/ctdSalinityProfile5m.pdf", width = 8, height = 5)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
https://github.com/cathmmitchell/plottingOceanDataWithR/wiki/Irregular-data
binned <- ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(depth_m < 10) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mutate_at(5, round)%>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
group_by(distance, tide, depth_m) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
summarize(av_tmp = mean(temp_c))
`summarise()` has grouped output by 'distance', 'tide'. You can override using the `.groups` argument.Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# flip order so higher temps are at the top!
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
binned
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
tempplot <- ggplot(binned,aes(x=distance,y=-1*(depth_m))) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
facet_grid(rows = vars(tide))+
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_contour_filled(aes(z=av_tmp), alpha = 0.8) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_point(size =0.1) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme_bw()+
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme(
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.x = element_text(margin = margin(t=10)),
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.y = element_text(margin = margin(r=10))) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
labs(y = "Depth (m)",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
x = "Distance from hatchery pens (m)",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
fill = "Temperature (C)") +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
scale_x_continuous(expand = c(0,0)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
scale_y_continuous(expand = c(0,0.05)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
scale_fill_brewer(palette = "Spectral", direction = -1,
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
guide = guide_legend(reverse = T))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
tempplot
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggsave("pdf_outputs/ctdTemp10metersDistance.png", width = 8, height = 5)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Why do some of the top depth values drop out? Something about the binning.
Do it once more, but setting the depth even shallower:
binned2 <- ctd.w.tides.dist %>%
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
filter(depth_m < 2.5) %>%
mutate_at(5, round, 2)%>%
group_by(distance, tide, depth_m) %>%
summarize(av_tmp = mean(temp_c))
`summarise()` has grouped output by 'distance', 'tide'. You can override using the `.groups` argument.
ggplot(binned2,aes(x=distance,y=-1*(depth_m))) +
facet_grid(rows = vars(tide))+
geom_contour_filled(aes(z=av_tmp), alpha = 0.8) +
geom_point(size =0.1) +
theme_bw()+
theme(
axis.title.x = element_text(margin = margin(t=10)),
axis.title.y = element_text(margin = margin(r=10))) +
labs(y = "Depth (m)",
x = "Distance from hatchery pens (m)",
fill = "Temperature (C)")
ggsave("pdf_outputs/ctdTemp3metersDistance.pdf", width = 8, height = 5)
For salinity and temp, let’s zoom in on the top 5 meters (we took samples from the first ~1 m)
# temp
ctd.w.tides.dist %>%
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
filter(depth_m < 5) %>%
ggplot(aes(x = temp_c, y = -1*(depth_m), color = distance)) +
geom_point() +
facet_grid(rows = vars(tide)) +
theme_bw()+
theme(
axis.title.x = element_text(margin = margin(t=10)),
axis.title.y = element_text(margin = margin(r=10))) +
labs(y = "Depth (m)",
x = "Temperature (C)",
color = "Distance (m)")
ggsave("pdf_outputs/ctdTempProfile3metersDistance.pdf", width = 8, height = 5)
binnedSalinity <- ctd.w.tides.dist %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
filter(depth_m < 10) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mutate_at(5, round)%>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
group_by(distance, tide, depth_m) %>%
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
summarize(av_salinity = mean(salinity))
`summarise()` has grouped output by 'distance', 'tide'. You can override using the `.groups` argument.Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
# oranize colors
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
mycolors <- colorRampPalette(brewer.pal(9, "Oranges"))(11)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
salplot <- ggplot(binnedSalinity, aes(x = distance, y = -1*(depth_m))) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
facet_grid(rows = vars(tide)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_contour_filled(aes(z = av_salinity), alpha = 0.8) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
geom_point(size = 0.1) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme_bw() +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
theme(
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.x = element_text(margin = margin(t=10)),
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
axis.title.y = element_text(margin = margin(r=10))) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
labs(y = "Depth (m)",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
x = "Distance from hatchery pens (m)",
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
fill = "Salinity (PSU)") +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
scale_x_continuous(expand = c(0,0)) +
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
scale_y_continuous(expand = c(0,0.05))
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
salplot
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggsave("pdf_outputs/ctdSalinity10metersDistance.png", width = 8, height = 5)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
binnedSal2 <- ctd.w.tides.dist %>%
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
filter(depth_m < 2.5) %>%
mutate_at(5, round, 2)%>%
group_by(distance, tide, depth_m) %>%
summarize(av_sal = mean(salinity))
`summarise()` has grouped output by 'distance', 'tide'. You can override using the `.groups` argument.
ggplot(binnedSal2,aes(x=distance,y=-1*(depth_m))) +
facet_grid(rows = vars(tide))+
geom_contour_filled(aes(z=av_sal), alpha = 0.8) +
geom_point(size =0.1) +
theme_bw()+
theme(
axis.title.x = element_text(margin = margin(t=10)),
axis.title.y = element_text(margin = margin(r=10))) +
labs(y = "Depth (m)",
x = "Distance from hatchery pens (m)",
fill = "Salinity (PSU)")
ggsave("pdf_outputs/ctdSalinity3metersDistance.png", width = 8, height = 5)
library(patchwork)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
salplot + tempplot + plot_layout(nrow = 2) + plot_annotation(tag_levels = "A")
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ggsave("pdf_outputs/ctd_data2021_dualplot.png", width = 8, height = 8)
Error in exists(cacheKey, where = .rs.WorkingDataEnv, inherits = FALSE) :
invalid first argument
ctd.w.tides.dist %>%
group_by(tide) %>%
summarise(max(salinity))
Density
density1 <- ctd.w.tides.dist %>%
mutate(tide = ifelse(tide == "AM_incoming", "incoming tide (AM)", "outgoing tide (PM)")) %>%
filter(depth_m < 10) %>%
mutate_at(5, round)%>%
group_by(distance, tide, depth_m) %>%
summarize(av_density = mean(density)) # the avg needs to be taken for proper plotting in this way.
`summarise()` has grouped output by 'distance', 'tide'. You can override using the `.groups` argument.
ggplot(density1,aes(x=distance,y=-1*(depth_m))) +
facet_grid(rows = vars(tide))+
geom_contour_filled(aes(z=density), alpha = 0.8) +
geom_point(size =0.1) +
theme_bw()+
theme(
axis.title.x = element_text(margin = margin(t=10)),
axis.title.y = element_text(margin = margin(r=10))) +
labs(y = "Depth (m)",
x = "Distance from hatchery pens (m)",
fill = "Density (kg/m^3)")
Error in `geom_contour_filled()`:
! Problem while computing aesthetics.
ℹ Error occurred in the 1st layer.
Caused by error in `compute_aesthetics()`:
! Aesthetics are not valid data columns.
✖ The following aesthetics are invalid:
✖ `z = density`
ℹ Did you mistype the name of a data column or forget to add `after_stat()`?
Backtrace:
1. base (local) `<fn>`(x)
2. ggplot2:::print.ggplot(x)
4. ggplot2:::ggplot_build.ggplot(x)
5. ggplot2:::by_layer(...)
12. ggplot2 (local) f(l = layers[[i]], d = data[[i]])
13. l$compute_aesthetics(d, plot)
14. ggplot2 (local) compute_aesthetics(..., self = self)
Tide data was obtained from the NOAA Tides website: tidesandcurrents.noaa.gov
Look at joining the tide data with the ctd data based on time
# double check the sampling to see if it overlaps slack tide?
tides.hour2 %>%
filter(Date == "2022-05-05") %>%
left_join(., ctd.times.2022, by = c("hour", "ymd")) %>%
filter(tide == "AM_outgoing") %>%
mutate(sampling_period = ifelse(is.na(ctd_sample), "no", "yes")) %>%
filter(height_ft < min(height_ft)+1) %>%
ggplot(aes(x = long, y = lat, color = newdate)) +
geom_point()
Warning: Detected an unexpected many-to-many relationship between `x` and `y`.
Minimum tidal height was at 10:36; the parallel transect was sampled after 11 am, so it was as the tide turned.
# make supplemental figure
tidePlot2021 + tidePlot2022 +
plot_layout(ncol = 1) +
plot_annotation(tag_levels = "A")
ggsave("pdf_outputs/SIfigure_tideCycle_bothYears.png", width = 8, height = 8)